﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Model.ModelEventArgs;
using Model.Interfaces;
using Model.ModelClasses;

namespace View.Schools
{
    /// <summary>
    /// Interaction logic for CreateNewSchoolPanel.xaml
    /// </summary>
    public partial class CreateNewSchoolPanel : UserControl
    {
         
        public event EventHandler<SchoolEventArgs> AddNewSchoolEvent;
        public event EventHandler CancelAddNewSchoolEvent;
        
        public CreateNewSchoolPanel()
        {
            InitializeComponent();
        }

        private void cancelButtonClick(object sender, RoutedEventArgs e)
        {
            if (CancelAddNewSchoolEvent != null) CancelAddNewSchoolEvent(this, new EventArgs());
        }

        private void addButtonClick(object sender, RoutedEventArgs e)
        {
            messageLabel.Content = "Заполните все поля";


            var newSchool = new Model.ModelClasses.School
            {
                Name = nameSchoolTextBox.Text,
                AdditionalInformation = nameSchoolTextBox.Text,
                ContactInformation = new OrganizationContactInformation
                {
                    LandlinePhone = phoneSchoolTextBox.Text,
                    AdditionalPhone = phoneSchoolTextBox.Text,
                    Email = emailSchoolTextBox.Text,
                    Fax = emailSchoolTextBox.Text,
                    ContactPerson = directorSchoolTextBox.Text,
                    WebSite = emailSchoolTextBox.Text
                }
            };

            newSchool.Address = new OrganizationAddress
            {
                Street = new Street(),
                Building = buildingSchoolTextBox.Text
            };

            newSchool.Status = "MildSchool";

            SchoolEventArgs args = new SchoolEventArgs(newSchool);

            if (AddNewSchoolEvent != null)
                AddNewSchoolEvent.Invoke(this, args);


        }

        private bool Verify()
        {
            return false;
        }
    }
}